<template>
  <div class="home">
    <img alt="Vue logo" src="../../assets/logo.png">
    <button @click="loginSubmit">登 录</button>
  </div>
</template>

<script>
// @ is an alias to /src
import HelloWorld from '@/components/HelloWorld.vue'

export default {
  name: 'HomeView',
  mounted() {
  },
  methods: {
    async loginSubmit() {
      const params = {
        name: "admin",
        password: "admin"
      }
      const res = await this.$getAPIs(this, params, "登录","login", "loginIn");
      if (!res) return false;
      this.$store.dispatch("update_user_info", res.data)

      const menuList = await this.$getAPIs(this, { "parentMenuId": 999999 }, "登录","sys", "getMenuList");
      if (!menuList || menuList.data.length <= 0) {
        this.$store.dispatch("clear_user_info")
        return this.$message.error("获取菜单权限失败！")
      };
      this.$store.dispatch("UpdataSidBar", menuList.data)
      this.$router.push("/layout/home")
    },
  },
  components: {
    HelloWorld
  }
}
</script>
